//
//  TagView.m
//  ImGuider
//
//  Created by 王鹏宇 on 2017/7/2.
//  Copyright © 2017年 imguider. All rights reserved.
//

#import "TagView.h"

@implementation TagView


- (void)setTagsArray:(NSArray *)tagsArray {
    
    for (UIView * view in self.subviews) {
        [view removeFromSuperview];
        self.tagViewWidth.constant = 0.f;
    }
    NSInteger  total = tagsArray.count;
    if (tagsArray.count > 2) {
        total = 2;
    }
    for (int i = 0;i< total; i++) {
        UILabel * label = [[UILabel alloc] init];
        label.text = tagsArray[i];
        label.textAlignment = NSTextAlignmentCenter;
        label.textColor = kThemeColor;
        label.layer.cornerRadius = 7.5;
        label.layer.borderWidth = 1.f;
        label.font = Font(9);
        label.layer.borderColor = kThemeColor.CGColor;
        [self addSubview:label];
        
        if (i == 0) {
            label.frame = CGRectMake(0, 0, 40, 15);
            self.tagViewWidth.constant = 45;
//            label.textColor = [UIColor whiteColor];
//            label.layer.backgroundColor = kThemeColor.CGColor;
        }else if(i == 1){
            label.frame = CGRectMake(48, 0, 40, 15);
            self.tagViewWidth.constant = 93;
        }
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
